<html xmlns:th="http://www.thymeleaf.org"
	  th:with="ctx=${#httpServletRequest.contextPath}"
>
<head>
</head>
<script type="text/javascript" src="js/jqurey.js"></script>
<script type="text/javascript" src="js/basePath.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("#submit").click(function(){
			var userName = $("#userName").val();
			var userPassword=$("#userPassword").val();
			$.ajax({
				url:basePath()+"gologin",
				data:{userName:userName,userPassword:userPassword},
			 	xhrFields:{withCredentials:true},
		        beforeSend: function(XMLHttpRequest){},
		      //请求成功回调
		        success: function(data, textStatus){
		              alert("进来了");
		              alert(data.login);
		              alert(data.token);
		              console.log(textStatus);
		              if(data.login){
		                  localStorage.setItem("token",data.token);
		                  window.location.href =basePath()+"goindex";
		              }
		        },
		        complete: function(XMLHttpRequest, textStatus){
		            
		        },
		        error: function(){
		            alert("请求网络失败！。。。。。。");
		        }
			});
		});
	});
	
</script>
<body>
	用户名:<input id="userName" type="text" placeholder="请输入用户名"/>
	<br/>
	<br/>
	密&nbsp;&nbsp;&nbsp;&nbsp;码:<input id="userPassword" type="text" placeholder="请输入密码"/>
	<br/>
	<br/>
	<input type="submit" id="submit" value="登陆"/>
	
	<input type="button" id="button" value="跳转到index"/>
</body>
</html>